package model;

import java.io.Serializable;

import java.math.BigDecimal;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

@Entity
@NamedQueries( { @NamedQuery(name = "Conductor.findAll", query = "select o from Conductor o") })
public class Conductor implements Serializable {
    @Id
    @Column(name = "RUT_C", nullable = false, length = 10, insertable = false, updatable = false)
    private String rutC;
    @Column(unique = true)
    private BigDecimal telefono;
    @ManyToOne
    @JoinColumn(name = "RUT_C")
    private Personal personal1;
    @OneToMany(mappedBy = "conductor")
    private List<Mantencion> mantencionList;

    public Conductor() {
    }

    public Conductor(Personal personal1, BigDecimal telefono) {
        this.personal1 = personal1;
        this.telefono = telefono;
    }

    public String getRutC() {
        return rutC;
    }

    public void setRutC(String rutC) {
        this.rutC = rutC;
    }

    public BigDecimal getTelefono() {
        return telefono;
    }

    public void setTelefono(BigDecimal telefono) {
        this.telefono = telefono;
    }

    public Personal getPersonal1() {
        return personal1;
    }

    public void setPersonal1(Personal personal1) {
        this.personal1 = personal1;
        if (personal1 != null) {
            this.rutC = personal1.getRut();
        }
    }

    public List<Mantencion> getMantencionList() {
        return mantencionList;
    }

    public void setMantencionList(List<Mantencion> mantencionList) {
        this.mantencionList = mantencionList;
    }

    public Mantencion addMantencion(Mantencion mantencion) {
        getMantencionList().add(mantencion);
        mantencion.setConductor(this);
        return mantencion;
    }

    public Mantencion removeMantencion(Mantencion mantencion) {
        getMantencionList().remove(mantencion);
        mantencion.setConductor(null);
        return mantencion;
    }
}
